// 封装接口模块
import http from '@/utils/request'
// 导入store
// import store from '@/store'
// 封装登录的api接口
// 封装接口的时候前面最好加req
export const reqLogin = (mobile, code) => {
  return http({
    method: 'post',
    url: 'v1_0/authorizations',
    data: {
      mobile,
      code
    }
  })
}
// 获取个人资料
export const reqGetUserProfile = () => {
  return http({
    method: 'get',
    url: 'v1_0/user/profile'
  })
}
// 获取关注列表
export const reqGetUserFollowings = () => {
  return http({
    method: 'get',
    url: 'v1_0/user/followings'
  })
}
// 刷新token的接口
export const reqGetNewToken = (refresh_token) => {
  return http({
    method: 'put',
    url: 'v1_0/authorizations',
    headers: {
      Authorization: 'Bearer ' + refresh_token
    }
  })
}
/**
 * 获取用户个人信息 (用于个人中心页的渲染数据)
 */
export const reqGetUserInfo = () => {
  return http({
    method: 'get',
    url: '/v1_0/user'
  })
}

// 编辑资料提交api
export const reqSaveUserProfile = (data) => {
  return http({
    method: 'patch',
    url: 'v1_0/user/profile',
    data
  })
}

/**
 * 修改用户头像
 * @param {*} formData 收集文件对象的formData
 */
export const reqUpdatePhoto = (formData) => {
  return http({
    method: 'patch',
    url: '/v1_0/user/photo',
    data: formData
  })
}
